# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=cargo-generate
pkgver=0.22.0
pkgrel=0
pkgdesc="Use pre-existing git repositories as templates"
url="https://github.com/cargo-generate/cargo-generate"
license="MIT OR Apache-2.0"
# loongarch64: blocked by libc crate
arch="all !s390x !loongarch64" # fails to build nix crate
makedepends="cargo libgit2-dev openssl-dev cargo-auditable"
source="https://github.com/cargo-generate/cargo-generate/archive/v$pkgver/cargo-generate-$pkgver.tar.gz"
options="net" # fetch dependencies

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libs
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		git2 = { rustc-link-lib = ["git2"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release --no-default-features
}

check() {
	cargo test --frozen --lib --no-default-features
}

package() {
	install -Dm755 target/release/$pkgname -t "$pkgdir"/usr/bin/
}

sha512sums="
6f29ab6e465b19a0ab0cf0415180ca9fc1267bcb214f9c02457934be4548c2033b4e54b73e0b11127bd729b27b5d679cc87115b069b71ccf5a3dbfabec56d578  cargo-generate-0.22.0.tar.gz
"
